package company.meituan_F;

import java.util.Scanner;

public class LianXi2 {

    // 改进版的背包问题
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        while (s != 0) {
            int n = sc.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = sc.nextInt();
            }
            int minCount = getMinCount(s, nums);
            System.out.println(minCount == -1 ? "Impossible" : minCount);
            s = sc.nextInt();
        }
    }

    private static int getMinCount(int s, int[] nums) {
        int n = nums.length;
        int[][] dp = new int[n + 1][s + 1];
        for (int j = 1; j <= s; j++) {
            dp[0][j] = -1;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j <= s; j++) {
                if (nums[i - 1] > j)
                    dp[i][j] = dp[i - 1][j];
                else {
                    int min = Integer.MAX_VALUE;
                    for (int k = 0; k <= j / nums[i - 1]; k++) {
                        int tmp = dp[i - 1][j - k * nums[i - 1]];
                        if (tmp != -1)
                            min = Math.min(min, tmp + k);
                    }
                    dp[i][j] = min == Integer.MAX_VALUE ? -1 : min;
                }
            }
        }
//        for (int i = 0; i <= n; i++) {
//            System.out.println(Arrays.toString(dp[i]));
//        }
        return dp[n][s];
    }
}
